﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Common/MasterPages/Dialog.Master"
    AutoEventWireup="true" CodeBehind="UserSelector.aspx.cs" Inherits="DMS.Web.Common.ApplicationPages.UserSelector" %>

<%@ Register Src="~/Common/Controls/SelectedValues.ascx" TagName="SelectedValues"
    TagPrefix="uc1" %>
<%@ Register Src="~/Common/Controls/UserList.ascx" TagName="UserList" TagPrefix="uc2" %>
<%@ Register Src="~/Common/Controls/DepartmentTree.ascx" TagName="DepartmentTree"
    TagPrefix="uc3" %>
<%@ Register Src="~/Common/Controls/RoleTree.ascx" TagName="RoleTree" TagPrefix="uc4" %>
<%@ Register Src="~/Common/Controls/RoleMemberListCtrl.ascx" TagName="RoleMemberListCtrl"
    TagPrefix="uc5" %>
<%@ Register Src="../Controls/RoleList.ascx" TagName="RoleList" TagPrefix="uc6" %>
<%@ Register Src="../Controls/DetpartmentListCtrl.ascx" TagName="DetpartmentListCtrl"
    TagPrefix="uc7" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PageTitle" runat="server">
    <asp:Literal ID="lb_title" runat="server"></asp:Literal>
    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainHolder" runat="server">
    <script type="text/javascript">
        function showTagOnly(id) {
            var tag = document.getElementById(id);
            ChangeTab(tag, tag.index, 'selector');
            if ('userByOrgTag' != id)
                document.getElementById('userByOrgTag').style.display = 'none';
            if ('userByRoleTag' != id)
                document.getElementById('userByRoleTag').style.display = 'none';
            if ('orgTag' != id)
                document.getElementById('orgTag').style.display = 'none';
            if ('roleTag' != id)
                document.getElementById('roleTag').style.display = 'none';
            if ('myOfficeTag' != id)
                document.getElementById('myOfficeTag').style.display = 'none';
        }
    </script>
    <div class="vista__tab_xp vista__tab_container vista__tab_default">
        <div id="selector_tab" class="vista__tab_header">
            <span id="userByOrgTag" class="vista__tab_active" onclick="javascript:ChangeTab(this, 0, 'selector');">
                <span class="vista__tab_outer">
                    <span class="vista__tab_inner">
                        <span class="vista__tab_tab">
                        按部门选择用户 
                        </span>
                    </span>
                </span>
            </span>
            <span id="userByRoleTag" index="1" onclick="javascript:ChangeTab(this, 1, 'selector');">
                 <span class="vista__tab_outer">
                    <span class="vista__tab_inner">
                        <span class="vista__tab_tab">
                            按角色选择成员
                        </span>
                    </span>
                </span>
            </span> 
            <span id="orgTag" index="2" onclick="javascript:ChangeTab(this, 2, 'selector');">
                <span class="vista__tab_outer">
                    <span class="vista__tab_inner">
                        <span class="vista__tab_tab">
                            选择部门
                        </span>
                    </span>
                </span>
            </span> 
            <span id="roleTag" index="3" onclick="javascript:ChangeTab(this, 3, 'selector');">
                <span class="vista__tab_outer">
                    <span class="vista__tab_inner">
                        <span class="vista__tab_tab">
                            选择角色
                        </span>
                    </span>
                </span>
            </span> 
            <span id="myOfficeTag" index="4" onclick="javascript:ChangeTab(this, 4, 'selector');">
                 <span class="vista__tab_outer">
                    <span class="vista__tab_inner">
                        <span class="vista__tab_tab">
                            我的部室
                        </span>
                    </span>
                </span>
            </span>
        </div>
        <div class="vista__tab_body">
            <!-------------------- 用户选择器1:按架构选择 ------------------>
            <div id="selector_0" class="vista__tab_panel">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <div style="padding-top: 5px;">
                            <table cellpadding="1" cellspacing="2" border="0" width="100%">
                                <tr>
                                    <td width="180px">
                                        <div style="width: 100%; height: 320px; vertical-align: top; overflow: auto;">
                                            <uc3:DepartmentTree ID="deptTree" runat="server" ShowCheckBoxes="None" OnNodeClick="DeptTree_NodeClick" />
                                        </div>
                                    </td>
                                    <td valign="top">
                                        <uc2:UserList ID="userList" runat="server" Mode="SingleSelector" OnClientSelectBtnClick="AddItem('用户：%Name%（%DeptFullName%）', '<Actor Type=\'%ActorType%\' ID=\'%ID%\' LoginID=\'%LoginID%\' Name=\'%Name%\' />')" />
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
            <!------------------ 用户选择器2:按角色选择 ------------------>
            <div id="selector_1" class="vista__tab_panel" style="display: none;">
                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                    <ContentTemplate>
                        <div style="padding-top: 5px;">
                            <table cellpadding="1" cellspacing="2" border="0" width="100%">
                                <tr>
                                    <td width="180px">
                                        <div style="width: 100%; height: 320px; vertical-align: top; overflow: auto;">
                                            <uc4:RoleTree ID="tvRole" runat="server" ShowCheckBoxes="None" OnNodeClick="tvRole_NodeClick"
                                                RootNodeText="成员角色" />
                                        </div>
                                    </td>
                                    <td valign="top">
                                        <uc5:RoleMemberListCtrl ID="roleMemberList" runat="server" Mode="SingleSelector"
                                        OnClientSelectBtnClick="AddItem('用户：%Name%（%DeptFullName%）', '<Actor Type=\'%ActorType%\' ID=\'%ID%\' LoginID=\'%LoginID%\' Name=\'%Name%\' />')" />
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
            <!------------------ 部门选择器 ------------------>
            <div id="selector_2" class="vista__tab_panel" style="display: none;">
                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                    <ContentTemplate>
                        <div style="padding-top: 5px;">
                            <table cellpadding="1" cellspacing="2" border="0" width="100%">
                                <tr>
                                    <td width="180px">
                                        <div style="width: 100%; height: 320px; vertical-align: top; overflow: auto;">
                                            <uc3:DepartmentTree ID="DeptTree2" runat="server" ShowCheckBoxes="None" OnNodeClick="DeptTree2_NodeClick" />
                                        </div>
                                    </td>
                                    <td valign="top">
                                        <uc7:DetpartmentListCtrl ID="DeptList" runat="server" Mode="SingleSelector"  OnClientSelectBtnClick="AddItem('部门：%Name%', '<Actor Type=\'%ActorType%\' ID=\'%ID%\' Name=\'%Name%\' />')"/>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
            <!------------------ 角色选择器 ------------------>
            <div id="selector_3" class="vista__tab_panel" style="display: none;">
                <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                    <ContentTemplate>
                        <div style="padding-top: 5px;">
                            <table cellpadding="1" cellspacing="2" border="0" width="100%">
                                <tr>
                                    <td valign="top" width="180px">
                                        <div style="width: 100%; height: 320px; vertical-align: top; overflow: auto;">
                                            <uc6:RoleList ID="RoleList1" runat="server" Mode="SingleSelector"
                                            OnClientSelectBtnClick="AddItem('角色：%Name%', '<Actor Type=\'%ActorType%\' ID=\'%ID%\' Name=\'%Name%\' RoleType=\'%Type%\' />')" />
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
            <!------------------ 用户选择器3：我的部室 ------------------>
            <div id="selector_4" class="vista__tab_panel" style="display: none;">
                <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                    <ContentTemplate>
                        <div style="padding-top: 5px;">
                            <div style="width: 100%; height: 320px; vertical-align: top; overflow: auto;">
                                我所在部门“<asp:Label ID="lblUserDept" runat="server"></asp:Label>”同事：
                                <uc2:UserList ID="userList1" runat="server" Mode="SingleSelector" EnableSearch="true"
                                    OnClientSelectBtnClick="AddItem('用户：%Name%（%DeptFullName%）', '<Actor Type=\'%ActorType%\' ID=\'%ID%\' LoginID=\'%LoginID%\' Name=\'%Name%\' />')" />
                            </div>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
    </div>
    <div width="100%">
        <uc1:SelectedValues ID="SValues" runat="server" RootTitle="Actors" ItemTitle="Actor"
            ItemSeparator="" Rows="5" />
    </div>
    <script language="javascript" type="text/javascript">
    <!--
        function Save() {
            var res = GetSelectedItems();
            if (res != "") {
                window.returnValue = res;
            }
            //            alert(res);
            window.close();
        }

        function ChangeTab(obj, cTabID, prefix) {
            var holder = document.getElementById(prefix + "_tab");
            if (holder == null) {
                return;
            }

            var tabs = holder.children;
            if (tabs == null || tabs.length == 0) {
                return;
            }

            for (var index = 0; index < holder.children.length; index++) {
                var tab = tabs[index];
                var tabContent = document.getElementById(prefix + "_" + index.toString());

                if (tabContent != null && tab != null) {
                    tab.className = "";
                    tabContent.style.display = "none";
                    if (cTabID == index) {
                        tab.className = "vista__tab_active";
                        tabContent.style.display = "block";
                    }
                }
            }
        }
    //-->
    </script>
</asp:Content>

<asp:Content ID="ctFooter"  ContentPlaceHolderID="FooterHolder" runat="server">
<asp:LinkButton ID="btnSave" CssClass="linkbtn" runat="server" OnClientClick="Save();"
        CausesValidation="true"><span>保存</span></asp:LinkButton>&nbsp;&nbsp;
<a href="javascript:window.close();" class="linkbtn"><span>关闭</span></a>
</asp:Content>